package iflyer.web;

import iflyer.model.ProductInfo;
import iflyer.service.ProductInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.Date;

/**
 * @ClassName ProductInfoController
 * @Author babylct
 * @Date 2018/7/20 15:07
 * @Version 1.0
 */
@RestController
@RequestMapping("/buyer/productInfo")
public class ProductInfoController {

    @Autowired
    private ProductInfoService productInfoService;

    @RequestMapping(value = "{id}/user", method = RequestMethod.GET)
    public ProductInfo getUserInfo(@PathVariable(name = "id") Long id) {
        ProductInfo productInfo = productInfoService.selectByPrimaryKey(id);
        return productInfo;
    }

    @RequestMapping(value = "/save", method = RequestMethod.GET)
    public int saveUserInfo() {
        ProductInfo productInfo = new ProductInfo();
        productInfo.setCategoryId(2L);
        productInfo.setCategoryType("003");
        productInfo.setProductName("男装");
        productInfo.setProductPrice(new BigDecimal(288));
        productInfo.setStatus("T");
        productInfo.setProductStock(9L);
        productInfo.setGmtCreate(new Date());
        productInfo.setGmtCreate(new Date());
        productInfo.setCreator("SYSTEM");
        productInfo.setModifier("SYSTEM");
        int user = productInfoService.insert(productInfo);
        return user;
    }
}
